package service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;

import pojo.User;
import service.UserManager;

public class UserManagerImpl implements UserManager{
	private List<User> users = new ArrayList<User>();
	
	public UserManagerImpl(){
		User u = new User("sample_id", "sample_name", true, 123.4, new Date());
		users.add(u);
	}

	@Override
	public int addUser(User user) {
		boolean b;
		synchronized (users) {
			user.setId(UUID.randomUUID().toString());
			b = users.add(user);
		}
		if(b){
			return 1;
		}else{
			return -1;
		}
	}

	@Override
	public List<User> findAll() {
		return users;
	}

}
